home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / PASSDK30.ZIP;1 / DISK1.ZIP / PAS / SUBS / VIDEO / VIDEO.ASM < prev   
Encoding:
Assembly Source File  |  1993-02-24  |  24.1 KB  |  1,248 lines

  1. ;$Author:   DCODY  $
  2. ;$Date:   24 Feb 1993 16:19:18  $
  3. ;$Header:   X:/sccs/video/video.asv   1.3   24 Feb 1993 16:19:18   DCODY  $
  4. ;$Log:   X:/sccs/video/video.asv  $
  5. ;  
  6. ;     Rev 1.3   24 Feb 1993 16:19:18   DCODY
  7. ;  corrected a model size problem in parameter passing.
  8. ;  
  9. ;     Rev 1.2   08 Dec 1992 17:27:24   DCODY
  10. ;  corrected some large model problems with parameter passing
  11. ;  
  12. ;     Rev 1.1   29 Oct 1992 14:47:52   DCODY
  13. ;  tiny model data declaration is corrected
  14. ;  
  15. ;     Rev 1.0   15 Jun 1992 09:45:32   BCRANE
  16. ;  Initial revision.
  17. ;$Logfile:   X:/sccs/video/video.asv  $
  18. ;$Modtimes$
  19. ;$Revision:   1.3  $
  20. ;$Workfile:   video.asm  $ 
  21.  
  22.     Title    Video.asm  -- Media Vision simple video routines
  23.     page    64,131
  24.  
  25. ;   /*\
  26. ;---|*|
  27. ;---|*|----=====< Video.asm >====-----
  28. ;---|*|
  29. ;---|*| This module provides video bios services for the caller.
  30. ;---|*|
  31. ;   \*/
  32.  
  33.         .xlist
  34.     include model.inc
  35.     include masm.inc
  36.     .list
  37.  
  38. ;
  39. ;   /*\
  40. ;---|*|----====< _ttyout ( char *, char *,...0 ) >====----
  41. ;---|*|
  42. ;---|*|  This routine writes the text strings out via TTY
  43. ;---|*|
  44. ;---|*|  On Entry:
  45. ;---|*|     int1 is the AND mask
  46. ;---|*|     int2 is the XOR mask
  47. ;---|*|     rect * is rectangle to pop
  48. ;---|*|
  49. ;---|*|  On Exit:
  50. ;---|*|     Nothing
  51. ;---|*|
  52. ;---|*|----====< _videoattr (int1, int2, rect * ) >====----
  53. ;---|*|
  54. ;---|*|  This routine will AND/XOR the contents of the rectangle
  55. ;---|*|
  56. ;---|*|  On Entry:
  57. ;---|*|     int1 is the AND mask
  58. ;---|*|     int2 is the XOR mask
  59. ;---|*|     rect * is rectangle to pop
  60. ;---|*|
  61. ;---|*|  On Exit:
  62. ;---|*|     Nothing
  63. ;---|*|
  64. ;---|*|----====< int _videocard () >====----
  65. ;---|*|
  66. ;---|*|  This routine returns the active adapter type
  67. ;---|*|
  68. ;---|*|  On Entry:
  69. ;---|*|     Nothing
  70. ;---|*|
  71. ;---|*|  On Exit:
  72. ;---|*|     ax = 1=hgc/mono,2=cga,4=ega,8=vga, 0=error
  73. ;---|*|
  74. ;---|*|----====< _videofill (int1, int2, rect * ) >====----
  75. ;---|*|
  76. ;---|*|  This routine will FILL the contents of the rectangle
  77. ;---|*|
  78. ;---|*|  On Entry:
  79. ;---|*|     int1 is the character
  80. ;---|*|     int2 is the attribute
  81. ;---|*|     rect * is rectangle to pop
  82. ;---|*|
  83. ;---|*|  On Exit:
  84. ;---|*|     Nothing
  85. ;---|*|
  86. ;---|*|
  87. ;---|*|----=====< long _videogetcurs () >====-----
  88. ;---|*|
  89. ;---|*| This function returns the cursor position
  90. ;---|*|
  91. ;---|*|   On Exit:
  92. ;---|*|
  93. ;---|*|     DX holds the column position
  94. ;---|*|     AX holds the row    position
  95. ;---|*|
  96. ;---|*|
  97. ;---|*|----=====< void _videosetcurs ( int1, int2 ) >====-----
  98. ;---|*|
  99. ;---|*| This function sets the cursor position
  100. ;---|*|
  101. ;---|*|   On Entry:
  102. ;---|*|
  103. ;---|*|     int1 is the row
  104. ;---|*|     int2 is the column
  105. ;---|*|
  106. ;---|*|
  107. ;---|*|----=====< void _videopage ( int1 ) >====-----
  108. ;---|*|
  109. ;---|*| This function sets the current video page
  110. ;---|*|
  111. ;---|*|   On Entry:
  112. ;---|*|
  113. ;---|*|     int1 is the page #
  114. ;---|*|
  115. ;---|*|
  116. ;---|*|----=====< void _videocshape  ( int1, int2 ) >====-----
  117. ;---|*|
  118. ;---|*| This function sets the cursor shape
  119. ;---|*|
  120. ;---|*|   On Entry:
  121. ;---|*|
  122. ;---|*|     int1 is the starting cursor scan line
  123. ;---|*|     int2 is the ending   cursor scan line
  124. ;---|*|
  125. ;---|*|
  126. ;---|*|----=====< void _videoint     ( &int1, &int2, &int3, &int4 ) >====-----
  127. ;---|*|
  128. ;---|*| This module provides any video bios services for the caller.
  129. ;---|*|
  130. ;---|*|   On Entry:
  131. ;---|*|
  132. ;---|*|     &int1-int4 are pointers to integers for registers AX,BX,CX,DX
  133. ;---|*|
  134. ;---|*|   On Exit:
  135. ;---|*|
  136. ;---|*|     AX,BX,CX,DX returned in &int1-int4 respectively
  137. ;---|*|
  138. ;---|*|----=====< void _zipout ( char * ) >====-----
  139. ;---|*|
  140. ;---|*| This routine writes an ASCIIZ string to the screen at the
  141. ;---|*| current cursor position.
  142. ;---|*|
  143. ;---|*|   On Entry:
  144. ;---|*|
  145. ;---|*|     char * is a pointer to the string
  146. ;---|*|
  147. ;---|*|   On Exit:
  148. ;---|*|
  149. ;---|*|     AX,BX,CX,DX returned in &int1-int4 respectively
  150. ;---|*|
  151. ;   \*/
  152.  
  153. if MODELSIZE eq 0
  154.     .code
  155. else
  156.     .data
  157. endif
  158.  
  159. rect    struc
  160.  xmin    dw    0
  161.  ymin    dw    0
  162.  xmax    dw    0
  163.  ymax    dw    0
  164. rect    ends
  165.  
  166. video    struc
  167.  wndr    dw    4 dup (0)    ; screen X,Y
  168.  row    dw    0        ; current cursor row
  169.  col    dw    0        ; current cursor column
  170.  attr    db    0        ; attribute
  171.  wrap    db    0        ; wrap flag
  172.  soff    dw    0        ; current screen offset
  173.  sseg    dw    0        ; current screen segment
  174. video    ends
  175.  
  176. VideoPage    db     0    ; save a copy for speed!
  177. OrigCursShape    dw    -1    ; cursor shape
  178.  
  179. if @datasize
  180.     Extrn    CurWnd:dword    ; pointer to window block
  181. else
  182.     Extrn    CurWnd:word    ; pointer to window block
  183. endif
  184.  
  185. BLACK_bk    equ    000h
  186. BLUE_bk     equ    010h
  187. GREEN_bk    equ    020h
  188. CYAN_bk     equ    030h
  189. RED_bk        equ    040h
  190. PURPLE_bk    equ    050h
  191. BROWN_bk    equ    060h
  192. GREY_bk     equ    070h
  193.  
  194. BLACK_fg    equ    000h
  195. BLUE_fg     equ    001h
  196. GREEN_fg    equ    002h
  197. CYAN_fg     equ    003h
  198. RED_fg        equ    004h
  199. PURPLE_fg    equ    005h
  200. BROWN_fg    equ    006h
  201. GREY_fg     equ    007h
  202. IBLACK_fg    equ    008h
  203. IBLUE_fg    equ    009h
  204. IGREEN_fg    equ    00Ah
  205. ICYAN_fg    equ    00Bh
  206. IRED_fg     equ    00Ch
  207. IPURPLE_fg    equ    00Dh
  208. IBROWN_fg    equ    00Eh
  209. WHITE_fg    equ    00Fh
  210.  
  211. attributetable    label    byte
  212.     db    GREY_fg     ;  0    CYAN_bk +
  213.     db    IGREEN_fg    ;  1    CYAN_bk +
  214.     db    GREY_fg     ;  2    CYAN_bk +
  215.     db    GREY_fg     ;  3    CYAN_bk +
  216.     db    GREY_fg     ;  4    CYAN_bk +
  217.     db    GREY_fg     ;  5    CYAN_bk +
  218.     db    GREY_fg     ;  6    CYAN_bk +
  219.     db    IGREEN_fg    ;  7    CYAN_bk +
  220.     db    GREY_fg     ;  8    CYAN_bk +
  221.     db    GREY_fg     ;  9    CYAN_bk +
  222.     db    GREY_fg     ;  a    CYAN_bk +
  223.     db    GREY_fg     ;  b    CYAN_bk +
  224.     db    GREY_fg     ;  c    CYAN_bk +
  225.     db    GREY_fg     ;  d    CYAN_bk +
  226.     db    GREY_fg     ;  e    CYAN_bk +
  227.     db    GREY_fg     ;  f    CYAN_bk +
  228.  
  229.     db    IGREEN_fg    ; 10    CYAN_bk +
  230.     db    IGREEN_fg    ; 11    CYAN_bk +
  231.     db    GREY_fg     ; 12    CYAN_bk +
  232.     db    GREY_fg     ; 13    CYAN_bk +
  233.     db    GREY_fg     ; 14    CYAN_bk +
  234.     db    GREY_fg     ; 15    CYAN_bk +
  235.     db    GREY_fg     ; 16    CYAN_bk +
  236.     db    GREY_fg     ; 17    CYAN_bk +
  237.     db    GREY_fg     ; 18    CYAN_bk +
  238.     db    GREY_fg     ; 19    CYAN_bk +
  239.     db    0        ; 1a    0
  240.     db    0        ; 1b    0
  241.     db    GREY_fg     ; 1c    CYAN_bk +
  242.     db    GREY_fg     ; 1d    CYAN_bk +
  243.     db    GREY_fg     ; 1e    CYAN_bk +
  244.     db    GREY_fg     ; 1f    CYAN_bk +
  245.  
  246.     db    0        ; 20
  247.     db    BLACK_fg    ; 21    CYAN_bk +
  248.     db    BLACK_fg    ; 22    CYAN_bk +
  249.     db    BLACK_fg    ; 23    CYAN_bk +
  250.     db    BLACK_fg    ; 24    CYAN_bk +
  251.     db    BLACK_fg    ; 25    CYAN_bk +
  252.     db    BLACK_fg    ; 26    CYAN_bk +
  253.     db    BLACK_fg    ; 27    CYAN_bk +
  254.     db    BLACK_fg    ; 28    CYAN_bk +
  255.     db    BLACK_fg    ; 29    CYAN_bk +
  256.     db    BLACK_fg    ; 2a    CYAN_bk +
  257.     db    BLACK_fg    ; 2b    CYAN_bk +
  258.     db    BLACK_fg    ; 2c    CYAN_bk +
  259.     db    BLACK_fg    ; 2d    CYAN_bk +
  260.     db    BLACK_fg    ; 2e    CYAN_bk +
  261.     db    BLACK_fg    ; 2f    CYAN_bk +
  262.  
  263.     db    BLACK_fg    ; 30    CYAN_bk +
  264.     db    BLACK_fg    ; 31    CYAN_bk +
  265.     db    BLACK_fg    ; 32    CYAN_bk +
  266.     db    BLACK_fg    ; 33    CYAN_bk +
  267.     db    BLACK_fg    ; 34    CYAN_bk +
  268.     db    BLACK_fg    ; 35    CYAN_bk +
  269.     db    BLACK_fg    ; 36    CYAN_bk +
  270.     db    BLACK_fg    ; 37    CYAN_bk +
  271.     db    BLACK_fg    ; 38    CYAN_bk +
  272.     db    BLACK_fg    ; 39    CYAN_bk +
  273.     db    BLACK_fg    ; 3a    CYAN_bk +
  274.     db    BLACK_fg    ; 3b    CYAN_bk +
  275.     db    BLACK_fg    ; 3c    CYAN_bk +
  276.     db    BLACK_fg    ; 3d    CYAN_bk +
  277.     db    BLACK_fg    ; 3e    CYAN_bk +
  278.     db    BLACK_fg    ; 3f    CYAN_bk +
  279.  
  280.     db    BLACK_fg    ; 40    CYAN_bk +
  281.     db    BLACK_fg    ; 41    CYAN_bk +
  282.     db    BLACK_fg    ; 42    CYAN_bk +
  283.     db    BLACK_fg    ; 43    CYAN_bk +
  284.     db    BLACK_fg    ; 44    CYAN_bk +
  285.     db    BLACK_fg    ; 45    CYAN_bk +
  286.     db    BLACK_fg    ; 46    CYAN_bk +
  287.     db    BLACK_fg    ; 47    CYAN_bk +
  288.     db    BLACK_fg    ; 48    CYAN_bk +
  289.     db    BLACK_fg    ; 49    CYAN_bk +
  290.     db    BLACK_fg    ; 4a    CYAN_bk +
  291.     db    BLACK_fg    ; 4b    CYAN_bk +
  292.     db    BLACK_fg    ; 4c    CYAN_bk +
  293.     db    BLACK_fg    ; 4d    CYAN_bk +
  294.     db    BLACK_fg    ; 4e    CYAN_bk +
  295.     db    BLACK_fg    ; 4f    CYAN_bk +
  296.  
  297.     db    BLACK_fg    ; 50    CYAN_bk +
  298.     db    BLACK_fg    ; 51    CYAN_bk +
  299.     db    BLACK_fg    ; 52    CYAN_bk +
  300.     db    BLACK_fg    ; 53    CYAN_bk +
  301.     db    BLACK_fg    ; 54    CYAN_bk +
  302.     db    BLACK_fg    ; 55    CYAN_bk +
  303.     db    BLACK_fg    ; 56    CYAN_bk +
  304.     db    BLACK_fg    ; 57    CYAN_bk +
  305.     db    BLACK_fg    ; 58    CYAN_bk +
  306.     db    BLACK_fg    ; 59    CYAN_bk +
  307.     db    BLACK_fg    ; 5a    CYAN_bk +
  308.     db    BLACK_fg    ; 5b    CYAN_bk +
  309.     db    BLACK_fg    ; 5c    CYAN_bk +
  310.     db    BLACK_fg    ; 5d    CYAN_bk +
  311.     db    BLACK_fg    ; 5e    CYAN_bk +
  312.     db    BLACK_fg    ; 5f    CYAN_bk +
  313.  
  314.     db    BLACK_fg    ; 60    CYAN_bk +
  315.     db    BLACK_fg    ; 61    CYAN_bk +
  316.     db    BLACK_fg    ; 62    CYAN_bk +
  317.     db    BLACK_fg    ; 63    CYAN_bk +
  318.     db    BLACK_fg    ; 64    CYAN_bk +
  319.     db    BLACK_fg    ; 65    CYAN_bk +
  320.     db    BLACK_fg    ; 66    CYAN_bk +
  321.     db    BLACK_fg    ; 67    CYAN_bk +
  322.     db    BLACK_fg    ; 68    CYAN_bk +
  323.     db    BLACK_fg    ; 69    CYAN_bk +
  324.     db    BLACK_fg    ; 6a    CYAN_bk +
  325.     db    BLACK_fg    ; 6b    CYAN_bk +
  326.     db    BLACK_fg    ; 6c    CYAN_bk +
  327.     db    BLACK_fg    ; 6d    CYAN_bk +
  328.     db    BLACK_fg    ; 6e    CYAN_bk +
  329.     db    BLACK_fg    ; 6f    CYAN_bk +
  330.  
  331.     db    BLACK_fg    ; 70    CYAN_bk +
  332.     db    BLACK_fg    ; 71    CYAN_bk +
  333.     db    BLACK_fg    ; 72    CYAN_bk +
  334.     db    BLACK_fg    ; 73    CYAN_bk +
  335.     db    BLACK_fg    ; 74    CYAN_bk +
  336.     db    BLACK_fg    ; 75    CYAN_bk +
  337.     db    BLACK_fg    ; 76    CYAN_bk +
  338.     db    BLACK_fg    ; 77    CYAN_bk +
  339.     db    BLACK_fg    ; 78    CYAN_bk +
  340.     db    BLACK_fg    ; 79    CYAN_bk +
  341.     db    BLACK_fg    ; 7a    CYAN_bk +
  342.     db    BLACK_fg    ; 7b    CYAN_bk +
  343.     db    BLACK_fg    ; 7c    CYAN_bk +
  344.     db    BLACK_fg    ; 7d    CYAN_bk +
  345.     db    BLACK_fg    ; 7e    CYAN_bk +
  346.     db    BLACK_fg    ; 7f    CYAN_bk +
  347.  
  348.         .code
  349.  
  350. ;
  351. ;   /*\
  352. ;---|*|----====< BackupVideo ( rect *, char far *, int, int ) >====----
  353. ;---|*|
  354. ;---|*| Back up a rectangle in the current window
  355. ;---|*|
  356. ;---|*| void BackupVideo (rect *r, char far *b, int morex, int morey);
  357. ;---|*| Save the screen contents of rectangle X, plus some...
  358. ;---|*|
  359. ;---|*| Entry Conditions.
  360. ;---|*|     parm1 is a pointer to the rectangle
  361. ;---|*|     parm2 is a far pointer to the target buffer
  362. ;---|*|     parm3 is an int requesting x more rows to be save
  363. ;---|*|     parm4 is an int requesting x more colums to be save
  364. ;---|*|
  365. ;---|*| Exit Conditions:
  366. ;---|*|     nothing
  367. ;---|*|
  368. ;   \*/
  369.     public    BackupVideo
  370. BackupVideo    proc    near
  371.     push    bp
  372.     mov    bp,sp
  373.     push    si
  374.     push    di
  375.     push    ds
  376.     push    es
  377. ;
  378. ; calculate the screen area
  379. ;
  380.     call    calcarea
  381. ;
  382. a00:
  383.     push    cx
  384.     mov    cx,bx
  385.     rep    movsw
  386.     add    si,dx
  387.     pop    cx
  388.     loop    a00
  389.  
  390.     pop    es
  391.     pop    ds
  392.     pop    di
  393.     pop    si
  394.     pop    bp
  395.         ret
  396.  
  397. BackupVideo    endp
  398.  
  399. ;
  400. ;   /*\
  401. ;---|*|----====< calcarea >====----
  402. ;---|*|
  403. ;---|*| calculate the area to be moved
  404. ;---|*| the stack frame is pointed to by bp, as it entered into
  405. ;---|*| the caller's routine.
  406. ;---|*|
  407. ;---|*| Entry Conditions.
  408. ;---|*|     BP points to:
  409. ;---|*|       parm1 is a pointer to the rectangle
  410. ;---|*|       parm2 is a far pointer to the target buffer
  411. ;---|*|       parm3 is an int requesting xxx more rows to be save
  412. ;---|*|       parm4 is an int requesting xxx more colums to be save
  413. ;---|*|
  414. ;---|*| Exit Conditions:
  415. ;---|*|     ES:DI point to the char far * buffer
  416. ;---|*|     DS:SI point to the video screen
  417. ;---|*|     CX holds the # of rows to move
  418. ;---|*|     BX holds the # of columns to save (word count)
  419. ;---|*|     DX holds the # of columns to skip (byte count)
  420. ;---|*|     direction flag is set
  421. ;---|*|
  422. ;   \*/
  423.  
  424. if @datasize    ;; if large model, adjust for far pointers
  425.  
  426. parm1    equ    <wParm1>    ; dword
  427. parm2    equ    <wParm3>    ; dword
  428. parm3    equ    <wParm4+2>    ; word
  429. parm4    equ    <wParm4+4>    ; word
  430.  
  431. else
  432.  
  433. parm1    equ    <wParm1>    ; word
  434. parm2    equ    <wParm2>    ; dword
  435. parm3    equ    <wParm4>    ; word
  436. parm4    equ    <wParm5>    ; word
  437.  
  438. endif
  439.  
  440. calcarea        proc    near
  441.  
  442. ;
  443. ; get the pointer to the rectangle structure
  444. ;
  445. if @datasize
  446.     push    ds            ; to be popped later
  447.         lds     si,[parm1]              ; large model...
  448. else
  449.     mov    si,[parm1]        ; small model...
  450. endif
  451.  
  452. ;
  453. ; get the number of rows to be saved into cx
  454. ;
  455.     mov    cx,[si.xmax]        ; calculate the # of rows
  456.     mov    ax,[si.xmin]
  457.     sub    cx,ax
  458.     inc    cx
  459.  
  460.     mov    ah,80*2         ; ax holds the offset to the
  461.     mul    ah            ; start of the video buffer
  462.  
  463.     add    cx,[parm3]        ; add in any more lines
  464. ;
  465. ; get the number of columns to save in bx, columns to skip in dx
  466. ;
  467.     mov    bx,[si.ymax]        ; calculate the number of colums
  468.     sub    bx,[si.ymin]
  469.     add    ax,[si.ymin]
  470.         add     ax,[si.ymin]
  471.     inc    bx
  472.  
  473.     add    bx,[parm4]        ; add in any more columns
  474.  
  475.     mov    dx,80            ; calc the # of columns to skip
  476.     sub    dx,bx            ; bx holds the # of ints to move
  477.     shl    dx,1            ; dx holds the # of characters to skip
  478. ;
  479. ; load the screen segment:offset into ds:si
  480. ;
  481. if @datasize
  482.     pop    ds            ; restore ds temporarily
  483.         les     di,CurWnd               ; get the segment of the window pointer
  484.     mov    ds,es:[di.sseg]
  485. else
  486.     mov    di,CurWnd        ; get the segment of the window pointer
  487.     mov    ds,[di.sseg]
  488. endif
  489.         mov     si,ax                   ; si points to the start
  490. ;
  491. ; get the buffer pointer into es:di
  492. ;
  493.     les    di,[parm2]        ; get the buffer pointer
  494.  
  495.     cld                ; make sure we move forward
  496.     ret
  497.  
  498. calcarea    endp
  499.  
  500. ;
  501. ;   /*\
  502. ;---|*|----====< ChangeAttributes ( int, int, int, int ) >====----
  503. ;---|*|
  504. ;---|*| Change some attributes in the rectangle
  505. ;---|*|
  506. ;   \*/
  507.     public    ChangeAttributes
  508. ChangeAttributes proc
  509.     push    bp
  510.     mov    bp,sp
  511.     push    es
  512.     push    di
  513.  
  514. if @datasize
  515.     les    di,[CurWnd]
  516.     mov    es,es:[di.sseg]
  517. else
  518.     mov    di,[CurWnd]
  519.     mov    es,[di.sseg]
  520. endif
  521. ;
  522. chat00:
  523.     mov    cx,wParm4        ; get the ending column
  524.     mov    bx,wParm2        ; get the starting column
  525.     sub    cx,bx            ; cx holds the length
  526.     jb    chat20            ; skip if inverted
  527.  
  528.     inc    cx            ; include the starting columm
  529.  
  530.     mov    di,wParm1        ; get the row #
  531.     cmp    di,wParm3        ; skip out if past the end
  532.     ja    chatdone        ; exit now
  533.  
  534.     mov    ax,80*2
  535.     mul    di
  536.     xchg    ax,di
  537.     add    di,bx
  538.     add    di,bx            ; di points to the end
  539.  
  540.     lea    bx,attributetable    ; get the attribute xlate table
  541.     ;
  542.     chat05:
  543.         mov     al,es:[di]
  544.     test    al,80h
  545.     jnz    chat07
  546.     xlat
  547.     or    al,al
  548.     jz    chat10
  549.     and    bptr es:[di+1],070h
  550.     or    es:[di+1],al
  551.     jmp    short chat10
  552.     ;
  553.     chat07:
  554.     and    bptr es:[di+1],77h
  555.     or    bptr es:[di+1],0Fh
  556.     ;
  557.     chat10:
  558.     inc    di
  559.         inc     di
  560.     loop    chat05            ; go for more
  561. ;
  562. chat20:
  563.     inc    wptr wParm1        ; move down the screen
  564.     jmp    short chat00
  565. ;
  566. chatdone:
  567.     pop    di
  568.     pop    es
  569.     pop    bp
  570.     ret
  571.  
  572. ChangeAttributes endp
  573.  
  574. ;
  575. ;   /*\
  576. ;---|*|----====< RestoreVideo ( rect *, char far *, int, int ) >====----
  577. ;---|*|
  578. ;---|*| void RestoreVideo (rect *r, char far *b, int morex, int morey);
  579. ;---|*|
  580. ;---|*| restore the screen contents of rectangle X, plus some...
  581. ;---|*|
  582. ;---|*| Entry Conditions.
  583. ;---|*|     parm1 is a pointer to the rectangle
  584. ;---|*|     parm2 is a far pointer to the source buffer
  585. ;---|*|     parm3 is an int requesting x more rows to be save
  586. ;---|*|     parm4 is an int requesting x more colums to be save
  587. ;---|*|
  588. ;---|*| Exit Conditions:
  589. ;---|*|     nothing
  590. ;---|*|
  591. ;   \*/
  592.     public    RestoreVideo
  593. RestoreVideo    proc    near
  594.         push    bp
  595.     mov    bp,sp
  596.     push    si
  597.     push    di
  598.     push    ds
  599.     push    es
  600. ;
  601. ; calculate the screen area
  602. ;
  603.     call    calcarea
  604. ;
  605. ; swap the pointers
  606. ;
  607.     push    es
  608.     push    ds
  609.     pop    es
  610.     pop    ds
  611.     xchg    si,di
  612. ;
  613. vr00:
  614. ;
  615. ; move the data back into the video buffer
  616. ;
  617.         push    cx
  618.     mov    cx,bx
  619.     rep    movsw
  620.     add    di,dx
  621.     pop    cx
  622.     loop    vr00
  623. ;
  624. ; all done, return home
  625. ;
  626.     pop    es
  627.     pop    ds
  628.     pop    di
  629.     pop    si
  630.     pop    bp
  631.         ret
  632.  
  633. RestoreVideo    endp
  634.  
  635. ;
  636. ;   /*\
  637. ;---|*|----====< _ttyout ( char *, char *,...0 );
  638. ;---|*|
  639. ;---|*|  This routine writes the text strings out via TTY
  640. ;---|*|
  641. ;---|*|  On Entry:
  642. ;---|*|     int1 is the AND mask
  643. ;---|*|     int2 is the XOR mask
  644. ;---|*|     rect * is rectangle to pop
  645. ;---|*|
  646. ;---|*|  On Exit:
  647. ;---|*|     Nothing
  648. ;---|*|
  649. ;   \*/
  650.     public    _ttyout
  651. _ttyout proc
  652.     push    bp
  653.     mov    bp,sp
  654.     push    ds
  655.     push    si
  656.  
  657.     lea    bp,wParm1        ; bp points to the next string
  658.     mov    bh,VideoPage        ; get the current page
  659.     cld
  660. ;
  661. to_05:
  662. if @datasize
  663.     lds    si,[bp]         ; get the next string
  664.     add    bp,4
  665.     mov    ax,ds
  666.     or    ax,si
  667. else
  668.     mov    si,[bp]         ; get the next string
  669.     add    bp,2
  670.     or    si,si
  671. endif
  672.     jz    to_exit         ; all done, exit home
  673.     mov    ah,0eh
  674. ;
  675. to_10:
  676.     lodsb                ; get the character
  677.     or    al,al
  678.     jz    to_05            ; go get the next string
  679.     int    10h
  680.     jmp    short to_10
  681. ;
  682. to_exit:
  683.     pop    si
  684.     pop    ds
  685.     pop    bp
  686.     ret
  687.  
  688. _ttyout endp
  689.  
  690. ;
  691. ;   /*\
  692. ;---|*|----====< _videoattr (int1, int2, rect * );
  693. ;---|*|
  694. ;---|*|  This routine will AND/XOR the contents of the rectangle
  695. ;---|*|
  696. ;---|*|  On Entry:
  697. ;---|*|     int1 is the AND mask
  698. ;---|*|     int2 is the XOR mask
  699. ;---|*|     rect * is rectangle to pop
  700. ;---|*|
  701. ;---|*|  On Exit:
  702. ;---|*|     Nothing
  703. ;   \*/
  704.  
  705.     public    _videoattr
  706. _videoattr      proc
  707.     push    bp
  708.     mov    bp,sp
  709.     push    ds
  710.         push    es
  711.     push    di
  712.     push    si
  713.  
  714. @psh    equ    (4*2)+2         ; 4 more words stored
  715.  
  716. lRows        equ    wptr [bp-@psh-0] ; # of rows to hit
  717. lCols        equ    wptr [bp-@psh-2] ; # of columns to hit
  718. lPtr        equ    wptr [bp-@psh-4] ; starting address
  719. lNext        equ    wptr [bp-@psh-6] ; offset to next address
  720.     sub    sp,8            ; save some more space
  721.  
  722. if @datasize
  723.     lds    si,wParm3        ; get the rectangle pointer
  724. else
  725.     mov    si,wParm3        ; get the rectangle pointer
  726. endif
  727.  
  728.         mov     ax,[si.xmin]
  729.     mov    dx,[si.xmax]
  730.     sub    dx,ax
  731.     inc    dx            ; bx has max rows
  732.     mov    lRows,dx
  733.  
  734.     mov    bl,80*2
  735.     mul    bl
  736.  
  737.     mov    cx,[si.ymin]
  738.     add    ax,cx
  739.     add    ax,cx            ; ax holds offset to video
  740.     mov    bx,[si.ymax]
  741.     sub    bx,cx
  742.     inc    bx            ; bx has max rows
  743.  
  744.     mov    lCols,bx
  745.  
  746.     cmp    dx,0            ; no rows, bomb out...
  747.     jbe    ViAt_exit
  748.     cmp    bx,0            ; no colums, bomb out...
  749.     jbe    ViAt_exit
  750.  
  751.     sub    bx,80            ; get next ptr count
  752.         neg     bx
  753.     add    bx,bx            ; double
  754.  
  755.     mov    lNext,bx
  756.  
  757. if @datasize
  758.     les    di,[CurWnd]
  759.     mov    es,es:[di.sseg]
  760. else
  761.     mov    di,[CurWnd]
  762.     mov    es,[di.sseg]
  763. endif
  764.  
  765.     mov    di,ax
  766.     inc    di            ; point to attributes
  767.  
  768.     mov    al,bptr wParm1        ; AND mask
  769.     mov    ah,wParm2        ; XOR mask
  770. ;
  771. ViAt_05:
  772.     mov    cx,lCols        ; refresh the column count
  773. ;
  774. ViAt_10:
  775.     and    es:[di],al
  776.     xor    es:[di],ah
  777.     add    di,2
  778.     loop    ViAt_10
  779.     add    di,lNext
  780.     dec    lRows
  781.     jnz    ViAt_05
  782. ;
  783. ; all done, exit home...
  784. ;
  785. ViAt_exit:
  786.     add    sp,8            ; toss out the local storage
  787.         pop     si
  788.         pop     di
  789.     pop    es
  790.     pop    ds
  791.     pop    bp
  792.     ret
  793.  
  794. _videoattr    endp
  795.  
  796. ;
  797. ;   /*\
  798. ;---|*|----====< int _videocard () >====----
  799. ;---|*|
  800. ;---|*|  This routine returns the active adapter type
  801. ;---|*|
  802. ;---|*|  On Entry:
  803. ;---|*|     Nothing
  804. ;---|*|
  805. ;---|*|  On Exit:
  806. ;---|*|     ax = 1=hgc/mono,2=cga,3=ega,4=vga
  807. ;   \*/
  808.     public    _videocard
  809. _videocard    proc            ; was a near here kdn
  810.     mov    ah,0fh            ; check for MONO card being active now
  811.     int    10h
  812.     cmp    al,07h            ; current mono mode?
  813.     mov    ax,1            ; (set just in case)
  814.     jz    vc_exit         ; yes, return it...
  815.  
  816.     mov    ax,1c00h
  817.     mov    cx,7
  818.     int    10h
  819.     cmp    al,1ch            ; VGA?
  820.     mov    al,08            ; (setup just in case)
  821.     jz    vc_exit         ; yes, exit now.
  822.  
  823.     mov    ah,12h            ; check EGA
  824.     mov    bl,10h
  825.     int    10h
  826.     cmp    bl,10h            ; changed? (EGA card?)
  827.     mov    al,04
  828.     jnz    vc_exit         ; yes, exit now
  829.  
  830.     mov    al,02            ; return CGA
  831. ;
  832. vc_exit:
  833.     cbw
  834.     ret
  835.  
  836. _videocard     endp
  837.  
  838. ;
  839. ;   /*\
  840. ;---|*|----====< _videofill (int1, int2, rect * );
  841. ;---|*|
  842. ;---|*|  This routine will fill the contents of the rectangle
  843. ;---|*|
  844. ;---|*|  On Entry:
  845. ;---|*|     int1 is the CHARACTER
  846. ;---|*|     int2 is the ATTRIBUTE
  847. ;---|*|     rect * is rectangle to pop
  848. ;---|*|
  849. ;---|*|  On Exit:
  850. ;---|*|     Nothing
  851. ;   \*/
  852.  
  853.     public    _videofill
  854. _videofill      proc
  855.     push    bp
  856.     mov    bp,sp
  857.     push    ds
  858.         push    es
  859.     push    di
  860.     push    si
  861.  
  862. @psh    equ    (4*2)+2         ; 4 registers stored
  863.  
  864. vfRows        equ    wptr [bp-@psh-0] ; # of rows to hit
  865. vfCols        equ    wptr [bp-@psh-2] ; # of columns to hit
  866. vfPtr        equ    wptr [bp-@psh-4] ; starting address
  867. vfNext        equ    wptr [bp-@psh-6] ; offset to next address
  868.         sub     sp,8                    ; save some more space
  869.  
  870. if @datasize
  871.     lds    si,wParm3        ; get the rectangle pointer
  872. else
  873.     mov    si,wParm3        ; get the rectangle pointer
  874. endif
  875.  
  876.         mov     ax,[si.xmin]
  877.     mov    dx,[si.xmax]
  878.     sub    dx,ax
  879.     inc    dx            ; bx has max rows
  880.     mov    vfRows,dx
  881.  
  882.     mov    bl,80*2
  883.     mul    bl
  884.  
  885.     mov    cx,[si.ymin]
  886.     add    ax,cx
  887.     add    ax,cx            ; ax holds offset to video
  888.     mov    bx,[si.ymax]
  889.     sub    bx,cx
  890.     inc    bx            ; bx has max rows
  891.  
  892.     mov    vfCols,bx
  893.  
  894.     cmp    dx,0            ; no rows, bomb out...
  895.     jbe    ViFi_exit
  896.     cmp    bx,0            ; no colums, bomb out...
  897.     jbe    ViFi_exit
  898.  
  899.     sub    bx,80            ; get next ptr count
  900.     neg    bx
  901.     add    bx,bx            ; double
  902.  
  903.     mov    vfNext,bx
  904.  
  905.  
  906. if @datasize
  907.     les    di,dptr [CurWnd]
  908.     mov    es,es:[di.sseg]
  909. else
  910.     mov    di,[CurWnd]
  911.     mov    es,[di.sseg]
  912. endif
  913.     mov    di,ax
  914.  
  915.     mov    al,wParm1        ; character
  916.     mov    ah,wParm2        ; attribute
  917.     cld
  918. ;
  919. ViFi_05:
  920.     mov    cx,vfCols        ; refresh the column count
  921.     rep    stosw
  922.     add    di,vfNext
  923.     dec    vfRows
  924.     jnz    ViFi_05
  925. ;
  926. ViFi_exit:
  927. ;
  928. ; all done, exit home...
  929. ;
  930.     add    sp,8            ; toss out the local storage
  931.         pop     si
  932.         pop     di
  933.     pop    es
  934.     pop    ds
  935.     pop    bp
  936.     ret
  937.  
  938. _videofill    endp
  939.  
  940. ;
  941. ;   /*\
  942. ;---|*|
  943. ;---|*|----=====< long _videogetcurs () >====-----
  944. ;---|*|
  945. ;---|*| This function returns the cursor position
  946. ;---|*|
  947. ;---|*|   On Exit:
  948. ;---|*|
  949. ;---|*|     DX holds the column position
  950. ;---|*|     AX holds the row    position
  951. ;---|*|
  952. ;---|*|
  953. ;   \*/
  954.     public    _videogetcurs
  955. _videogetcurs    proc
  956.     push    bp
  957.     mov    bp,sp
  958.  
  959.     mov    ah,03h
  960.     mov    bh,VideoPage
  961.     int    10h
  962.  
  963.     sub    ax,ax
  964.     xchg    al,dh
  965.  
  966.     pop    bp
  967.     ret
  968.  
  969. _videogetcurs    endp
  970.  
  971. ;
  972. ;   /*\
  973. ;---|*|
  974. ;---|*|----=====< void _videosetcurs ( int1, int2 ) >====-----
  975. ;---|*|
  976. ;---|*| This function sets the cursor position
  977. ;---|*|
  978. ;---|*|   On Entry:
  979. ;---|*|
  980. ;---|*|     int1 is the row
  981. ;---|*|     int2 is the column
  982. ;---|*|
  983. ;   \*/
  984.     public    _videosetcurs
  985. _videosetcurs    proc
  986.     push    bp
  987.     mov    bp,sp
  988.  
  989.     mov    ah,02h
  990.         mov     bh,VideoPage
  991.     mov    dl,byte ptr wParm2
  992.     mov    dh,byte ptr wParm1
  993.     int    10h
  994.  
  995.     pop    bp
  996.     ret
  997.  
  998. _videosetcurs    endp
  999.  
  1000. ;
  1001. ;   /*\
  1002. ;---|*|
  1003. ;---|*|----=====< void _videopage ( int1 ) >====-----
  1004. ;---|*|
  1005. ;---|*| This function sets the current video page
  1006. ;---|*|
  1007. ;---|*|   On Entry:
  1008. ;---|*|
  1009. ;---|*|     int1 is the page #
  1010. ;---|*|
  1011. ;---|*|
  1012. ;   \*/
  1013.  
  1014.     public    _videopage
  1015. _videopage      proc
  1016.     push    bp
  1017.     mov    bp,sp
  1018.  
  1019.     mov    ah,05h
  1020.     mov    al,byte ptr wParm1
  1021.     mov    VideoPage,al
  1022.         int     10h
  1023.  
  1024.     pop    bp
  1025.     ret
  1026.  
  1027. _videopage      endp
  1028.  
  1029. ;
  1030. ;   /*\
  1031. ;---|*|
  1032. ;---|*|----=====< void _videocshape  ( int1, int2 ) >====-----
  1033. ;---|*|
  1034. ;---|*| This function sets the cursor shape
  1035. ;---|*|
  1036. ;---|*|   On Entry:
  1037. ;---|*|
  1038. ;---|*|     int1 is the starting cursor scan line
  1039. ;---|*|     int2 is the ending   cursor scan line
  1040. ;---|*|
  1041. ;   \*/
  1042.  
  1043.     public    _videocshape
  1044. _videocshape    proc
  1045.     push    bp
  1046.     mov    bp,sp
  1047.  
  1048.     cmp    OrigCursShape,-1    ; is it -1?
  1049.     jnz    vish_found        ; no, already fetched...
  1050.     mov    ah,3            ; yes, get the original shape
  1051.     int    10h
  1052.     mov    OrigCursShape,cx    ; save the new shape
  1053. ;
  1054. vish_found:
  1055.     mov    cl,byte ptr wParm1    ; get the new shape
  1056.     mov    ch,byte ptr wParm2
  1057.     cmp    cx,-1            ; restoration request?
  1058.     jnz    vish_new
  1059.     mov    cx,OrigCursShape    ; yes, use it!
  1060.     cmp    cx,-1            ; oops it was never set
  1061.     jz    vish_done
  1062. ;
  1063. vish_new:
  1064.     mov    ah,01h
  1065.         int     10h
  1066. ;
  1067. vish_done:
  1068.     pop    bp
  1069.     ret
  1070.  
  1071. _videocshape    endp
  1072.  
  1073. ;
  1074. ;   /*\
  1075. ;---|*|
  1076. ;---|*|----=====< void _videoint     ( &int1, &int2, &int3, &int4 ) >====-----
  1077. ;---|*|
  1078. ;---|*| This module provides any video bios services for the caller.
  1079. ;---|*|
  1080. ;---|*|   On Entry:
  1081. ;---|*|
  1082. ;---|*|     &int1-int4 are pointers to integers for registers AX,BX,CX,DX
  1083. ;---|*|
  1084. ;---|*|   On Exit:
  1085. ;---|*|
  1086. ;---|*|     AX,BX,CX,DX returned in &int1-int4 respectively
  1087. ;---|*|
  1088. ;   \*/
  1089. ;
  1090.  
  1091.     public    _videoint
  1092. _videoint       proc
  1093.     push    bp
  1094.     mov    bp,sp
  1095. if @datasize
  1096.     push    es
  1097. endif
  1098.         push    si
  1099.  
  1100. if @datasize
  1101.     les    si,dParm1
  1102.     mov    ax,es:[si]
  1103. else
  1104.     mov    si,wParm1
  1105.     mov    ax,[si]
  1106. endif
  1107.  
  1108. if @datasize
  1109.     les    si,dParm2
  1110.     mov    bx,es:[si]
  1111. else
  1112.     mov    si,wParm2
  1113.     mov    bx,[si]
  1114. endif
  1115.  
  1116. if @datasize
  1117.     les    si,dParm3
  1118.     mov    cx,es:[si]
  1119. else
  1120.     mov    si,wParm3
  1121.     mov    cx,[si]
  1122. endif
  1123.  
  1124. if @datasize
  1125.     les    si,dParm4
  1126.     mov    dx,es:[si]
  1127. else
  1128.     mov    si,wParm4
  1129.     mov    dx,[si]
  1130. endif
  1131.  
  1132.         int     10h
  1133.  
  1134. if @datasize
  1135.     mov    es:[si],dx
  1136. else
  1137.     mov    [si],dx
  1138. endif
  1139. if @datasize
  1140.     les    si,dParm3
  1141.     mov    es:[si],cx
  1142. else
  1143.     mov    si,wParm3
  1144.     mov    [si],cx
  1145. endif
  1146.  
  1147. if @datasize
  1148.     les    si,dParm2
  1149.     mov    es:[si],bx
  1150. else
  1151.     mov    si,wParm2
  1152.     mov    [si],bx
  1153. endif
  1154.  
  1155. if @datasize
  1156.     les    si,dParm1
  1157.     mov    es:[si],ax
  1158. else
  1159.     mov    si,wParm1
  1160.     mov    [si],ax
  1161. endif
  1162.  
  1163.     pop    si
  1164. if @datasize
  1165.         pop     es
  1166. endif
  1167.         pop     bp
  1168.     ret
  1169.  
  1170. _videoint    endp
  1171.  
  1172. ;
  1173. ;   /*\
  1174. ;---|*|----====< _zipout ( char * ) >====----
  1175. ;---|*|
  1176. ;---|*| print the string at the current cursor position
  1177. ;---|*|
  1178. ;   \*/
  1179.  
  1180.     public    _zipout
  1181. _zipout proc                ;was a near here kdn
  1182.     push    bp
  1183.     mov    bp,sp
  1184.     push    ds
  1185.         push    es
  1186.     push    di
  1187.     push    si
  1188. ;
  1189. ; calculate the starting position
  1190. ;
  1191.     sub    bx,bx
  1192.     mov    es,bx
  1193.         mov     ah,0fh                  ; get the page number
  1194.     int    10h
  1195.     xchg    bh,bl            ; bx holds the cursor index
  1196.  
  1197.     mov    bx,es:[0450h]        ; get the x,y
  1198.  
  1199.     mov    di,0b000h        ; mono segment
  1200.     cmp    al,7
  1201.     jz    @F
  1202.     mov    di,0b800h
  1203.    @@:    mov    es,di
  1204.  
  1205.     mov    al,80*2         ; get the column width
  1206.     mul    bh            ; ax = row offset
  1207.     sub    bh,bh
  1208.     shl    bx,1            ; add colume offset
  1209.     add    ax,bx
  1210.  
  1211.     mov    di,ax            ; es:di point to the screen
  1212. ;
  1213. ; load other registers & rip!
  1214. ;
  1215.  
  1216. if @datasize
  1217.     lds    si,wParm1        ; get the next string
  1218. else
  1219.         mov     si,wParm1               ; get the string address
  1220. endif
  1221.  
  1222.     cld
  1223. ;
  1224. _zi05:
  1225.     lodsb                ; get the next character
  1226.     or    al,al
  1227.     jz    _zi10            ; done...
  1228.     stosb
  1229.     inc    di
  1230.     jmp    short _zi05
  1231. ;
  1232. _zi10:
  1233.     pop    si
  1234.     pop    di
  1235.     pop    es
  1236.     pop    ds
  1237.     pop    bp
  1238.     ret
  1239.  
  1240. _zipout endp
  1241.  
  1242.     end
  1243.  
  1244. ;   /*\
  1245. ;---|*| enf of VIDEO.ASM
  1246. ;   \*/
  1247.  
  1248.